<?php
/**
 * Created by PhpStorm.
 * User: xunuo
 * Date: 2017/6/27
 * Time: 13:04
 */

namespace app\company\widget;

use think\View;

class Industry
{
    /**
     * 列表树
     * @param int $pid
     * @param int $level
     * @return string|void
     */
    public function listTree($pid = '', $level = 0)
    {
        $industryModel = new \app\company\model\Industry();
        $data['list'] = $industryModel->getList($pid);

        if (empty($data['list'])) {
            return;
        }
        $data['level'] = $level;
        $view = new View();
        return $view->fetch('industry/listtree', $data);
    }

    /**
     * 选择上级分类树
     * @param int $pid
     * @return string|void
     */
    public function pidListTree($pid = '', $current = 0)
    {
        $industryModel = new \app\company\model\Industry();
        $data['list'] = $industryModel->getList($pid);
        if (empty($data['list'])) {
            return;
        }
        $data['current'] = $current;
        $view = new View();
        return $view->fetch('industry/pidlisttree', $data);
    }

    /**
     * 选择上级分类树
     * @param int $pid
     * @return string|void
     */
    public function pidListTrees($pid = '', $current = 0)
    {
        $Themeparam = new \app\company\model\Themeparam();
        $data['list'] = $Themeparam->getList($pid);
        if (empty($data['list'])) {
            return;
        }
        $data['current'] = $current;
        $view = new View();
        return $view->fetch('themeparam/pidlisttrees', $data);
    }

    /**
     * 选择上级分类树
     * @return string|void
     */
    public function chooseListTree($pid = '')
    {
        $industryModel = new \app\company\model\Industry();
        $data['list'] = $industryModel->getList($pid);
        if (empty($data['list'])) {
            return;
        }
        $view = new View();
        return $view->fetch('industry/chooselisttree', $data);
    }

    /**
     * 选择上级分类树只可选择下级
     * @return string|void
     */
    public function chooseLowestListTree($pid = '')
    {
        $industryModel = new \app\company\model\Industry();
        $data['list'] = $industryModel->getList($pid);
        if (empty($data['list'])) {
            return;
        }

        $view = new View();
        return $view->fetch('industry/chooselowestlisttree', $data);
    }
}